package com.example.springboot.demo;

import com.example.springboot.demo.service.EnableServer;
import com.example.springboot.demo.service.Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.annotation.PostConstruct;

@SpringBootApplication
@EnableServer(type = Server.type.HTTP)
public class DemoApplication {

    @Autowired
    ApplicationContext applicationContext;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);

    }

    @PostConstruct
    public void test() {
        Server server =  applicationContext.getBean(Server.class);
        server.start();
        server.stop();
    }

}
